home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / searchtools / refjoin < prev    next >
Text File  |  1994-08-01  |  1KB  |  41 lines

  1. #! /bin/sh
  2. #
  3. #  ~4Dgifts/toolbox/searchtools/refjoin functions.INDEX sifter/joiner utility
  4. #
  5. # Using the master function-keyword index, functions.INDEX, 
  6. # generated by getobjs, print the files containing the keyword(s).
  7. # If more than one arg is given, we use "join" to print only the 
  8. # files containing all the keywords.  This isn't the most optimal
  9. # algorithm, but for small numbers of keywords, it works
  10. # pretty well.
  11.  
  12. INDEX=searchtools/functions.INDEX
  13. echo=true
  14. if [ x"$1" = x-v ]; then echo=echo; shift; fi
  15.  
  16. if [ $# -lt 1 ]
  17. then echo "Usage: $0 keyword1 [ keyword2 ... ]" ; exit 1
  18. fi
  19.  
  20. if [ $# -eq 1 ]
  21. then exec searchtools/look $1 $INDEX
  22. fi
  23.  
  24. keywords="$@"
  25. trap "rm -f /tmp/rj*.$$" 0 1 15
  26. searchtools/look $1 $INDEX > /tmp/rj.$$
  27. shift
  28. filefield=2
  29.  
  30. while [ $# -ge 1 ]
  31. do
  32.     searchtools/look $1 $INDEX > /tmp/rj2.$$
  33.     join -j1 $filefield -j2 2 /tmp/rj.$$ /tmp/rj2.$$ > /tmp/rjj.$$
  34.     filefield=1
  35.     mv /tmp/rjj.$$ /tmp/rj.$$
  36.     shift
  37. done
  38.  
  39. $echo Files that contain the keywords:  "$keywords"
  40. sed -e 's/^/    /' -e 's/ .*//' /tmp/rj.$$
  41.